package yhq.webmagic;

import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.model.OOSpider;
import us.codecraft.webmagic.model.annotation.ExtractBy;
import us.codecraft.webmagic.model.annotation.TargetUrl;
import yhq.config.YhqData;
import yhq.config.YhqPageModelPipeline;

/**
 * Created by yanghongquan on 2018/8/31 11:11
 */
@TargetUrl("https://www.feixiaohao.com/notice/")
@ExtractBy(value = "//ul[@class=\"noticeList\"]/li",multi = true)
public class YhqTry {

    @ExtractBy(value = "//a[@class=web]/text()")
    private String webName;

    @ExtractBy(value = "//a[@class=tit]/text()")
    private String title;

    @ExtractBy(value = "//a[@class=tit]/span/text()")
    private String date;

    @Override
    public String toString() {
        return "yhqTry{" +
                "webName='" + webName + '\'' +
                ", title='" + title + '\'' +
                ", date='" + date + '\'' +
                '}';
    }

    public static void main(String[] args) {
        YhqData.reset();
        OOSpider.create(Site.me(), new YhqPageModelPipeline(), YhqTry.class).addUrl("https://www.feixiaohao.com/notice/").thread(4).run();
//        OOSpider ooSpider = OOSpider.create(Site.me().setSleepTime(200), new yhqPageModelPipeline(), yhqTry.class);
//        ooSpider.addUrl("https://www.feixiaohao.com/notice/").thread(4).run();
        System.out.println(YhqData.get(new YhqTry()));

//        ooSpider.close();
    }
}
